package controller.listeners.batchPosCodeCorps;


import model.BatchPosCodeCorpsModel;

import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;

import view.BatchPosCodeCorpsView;

public class PrevSelectionListener extends SelectionAdapter {

	private BatchPosCodeCorpsModel _model;
	private BatchPosCodeCorpsView _view;
	
	public PrevSelectionListener(BatchPosCodeCorpsView view, BatchPosCodeCorpsModel model) {
		this._model = model;
		this._view = view;
	}
	
	public void widgetSelected(SelectionEvent event) {
	String filter = _view.getCorpFilter();
		
		int pag = 0;
		try {
			pag = Integer.parseInt(filter);
			if (pag > 0)
				pag--;
		} catch (Exception e) {
			
		}
		//Limpio centros, corps, etc
	 	 _model.reset();
	 	 
	 	 _view.setCorpFilter(pag+"");
	 	 _model.setCorpFilter(pag+"");
	 	 
	 	 _model.set_custom_corp("");
	 	 
	 	 _view.setCachePreCodeCorps(_model.get_cache_precodecorps());
	 	 _view.setCandidateCenters(_model.getCandidateCenters());
		
	}
}
